import {
  Column,
  CreateDateColumn,
  Entity,
  PrimaryGeneratedColumn,
  UpdateDateColumn,
} from 'typeorm';

@Entity()
export class User {
  @PrimaryGeneratedColumn()
  id: number;
  @Column()
  username: string;
  @Column()
  password: string;
  @Column()
  pwdHash: string;
}

@Entity()
export class Standard {
  @PrimaryGeneratedColumn()
  id: number;
  @Column()
  name: string;
}

@Entity()
export class EquipmentModel {
  @PrimaryGeneratedColumn()
  id?: number;
  @Column()
  name: string;
  @Column('json')
  metaData: any;
  @Column('json')
  infoSchema: any;
  @Column('json')
  taskSchema: any;
  @Column()
  coverTemplate: string;
  //ref
  @Column()
  parentID: number;
}

@Entity()
export class EquipmentInstance {
  @PrimaryGeneratedColumn()
  id: number;
  @Column()
  name: string;
  @Column('json')
  data: any;
  //ref
  @Column()
  parentID: number;
  @Column()
  equipmentModelID: number;
}

@Entity()
export class Script {
  @PrimaryGeneratedColumn()
  id: number;
  @Column()
  ename: string;
  @Column('text')
  code: string;
  @Column()
  scopeType: string;
  @Column()
  scopeID: number;
}

@Entity()
export class TaskGroup {
  @PrimaryGeneratedColumn()
  id: number;
  @Column()
  status: string; // 进行中 已提交
  @Column()
  taskType: string; //预防性试验 诊断试验 交接试验

  @Column()
  docxReport: string;
  @Column()
  pdfReport: string;

  @CreateDateColumn()
  createdAt: Date;
  @UpdateDateColumn()
  updatedAt: Date;

  //ref
  @Column()
  equipmentInstanceID: number;
  @Column()
  standardID: number; //行业标准选择, 一个任务只能选一个
}
@Entity()
export class TaskGroupEquipmentInfo {
  @PrimaryGeneratedColumn()
  id: number;
  @Column('json')
  data: any;
  //ref
  @Column()
  taskGroupID: number;
}

@Entity()
export class TaskModel {
  @PrimaryGeneratedColumn()
  id: number;
  @Column()
  name: string;
  @Column()
  reportTemplate: string;
  @Column('json')
  amisSchema: any;
  //ref
  @Column()
  equipmentModelID: number;
}

@Entity()
export class TaskInstance {
  @PrimaryGeneratedColumn()
  id: number;
  @Column('json')
  data: any;
  @Column()
  docxReport: string;
  @Column()
  pdfReport: string;
  //ref
  @Column()
  taskGroupID: number;
  @Column()
  taskModelID: number;
}
